/**
 * @param {string[]} tokens
 * @return {number}
 */
 var evalRPN = function(tokens) {
    let n = tokens.length
    let stack = []
    let map = new Map([
        ['+',(a,b)=>a*1+b*1],
        ['-',(a,b)=>b-a],
        ['*',(a,b)=>a*b],
        ['/',(a,b)=>Math.trunc(b/a)]
    ])
    for(let i = 0;i<n;i++){
        if(map.has(tokens[i])){
           stack.push(map.get(tokens[i])(stack.pop(),stack.pop()))
        }else{
            stack.push(tokens[i])
        }
    }
    return stack[0]
};
console.log(evalRPN(["2","1","+","3","*"]));